scratchfandomcom-20200213-history
Blocks
Blocks '''are used to make all programming in the Scratch programming language. The blocks connect to each other, and each one has a different function, or value. They're divided into 8 types: Motion, Looks, Sound, Pen, Control, Sensing, Numbers and Variables. Types of blocks There are 5 kinds of blocks on Scratch: *"Hat": The basic block on Scratch - No program can run without this kind of block. All 4 hat blocks can be found on the "Control" section. The hat blocks activate when a certain event, like a key pressed, or the green flag clicked, happens. *'''Command: Most Scratch blocks are command blocks. These blocks tell the program to do a specific action, like moving or playing a sound. These blocks are shaped like a rectangle. *'"C"': These blocks wrap around a group of blocks (hence their name, due to their C shape), making the blocks run forever, or only under certain conditions. *'Boolean': These blocks are one of the two value blocks, and therefore have a variable value. They can be true or false, and are shaped like a hexagon. Some of the most used booleans are "key ___ pressed?", and "___ = ___". *'Value/Variable': These blocks hold a number or string value, like a score or level. Many of them can also be shown on the project as a "stage monitor", by clicking the checkbox next to them. They have a round shape. * "Caps": These blocks end or "cap the lid to" a script (or a the complete project), so no more blocks can be added to the end of the script. Examples of these include the "Stop Script" block and "Stop All" block. Block Categories Motion The blocks in the Motion category generally change the position or direction of a sprite. By going to extras, and clicking "Show Motor Blocks", you can activate 5 WeDo blocks for the LEGO® Education WeDo™ kit, which can be seen below. Also the motion blocks can be identified by their blue color. * (10) steps (Command): Move __ Steps is used when you want a sprite to move a certain number of steps. A negetive number can be used to make the sprite move backwards. All movement done using this block is done to the direction the sprite is heading to. *'⤾/⤿ (15) degrees (Command)': Turn __ degrees makes a sprite rotate. There are two variants of this block: Clockwise, and counter-clockwise. *'in direction (90 -) (Command)':' '''Makes the sprite point in a specific direction. In the drop-down menu, you can choose from 90 degrees (right), 180 degrees (down), -90 degrees (left), and 0 degrees (up). * 'towards [ -] (Command): Makes the sprite point towards another sprite. In the drop-down menu, you can choose from another sprite if there is any, or the mouse pointer. *to x: (0) y: (0) (Command):''' '''Makes a sprite go to a specific X and Y position. *to [ -]' '(Command):''' '''Makes a sprite go to the position of another sprite. Within the drop-down menu, you can choose from another sprite if there is any, or the mouse pointer. *(1) secs to x: (0) y: (0)' '(Command):''' '''Makes a sprite move smoothly to a specific X and Y position, in a specified amount of seconds. *x/y by (10) (Command):''' '''Changes the X or Y postion of a sprite by the specified amount. *x/y to (0) (Command): Sets the X or Y postion of a sprite to the specified amount. *on edge, bounce (Command): If the sprite is touching the edge, makes it point at the opposite direction, providing a neat "bounce" effect. *(x/y-position) (Value/Variable):''' '''It's value is the current X or Y position of the sprite. Can be displayed as a stage monitor. *(direction) (Value/Variable): It's value is the direction, in 360º degree format, that the sprite is pointing to. For unknown reasons, Scratch's degrees go from -180 to 180, rather than from 0 to 360, unlike other programming languages. Can be displayed as a stage monitor. Looks The blocks in the Looks category generally effect how a sprite appears on the screen. Also the looks blocks can be identified by their blue-ish purple color. *to costume [costume1 -] (Command): Switches the sprite's costume to a specified costume. *costume(Command): Switches the sprite's costume to the next costume after the current. *(costume#) (Value/Variable): It's value is the number of the current sprite's costume. Can be displayed as a stage monitor. *[Hello! for (2) secs] (Command): The sprite "says" a phrase inside a speech bubble, for a specified amount of seconds. *[Hello!] (Command): The sprite "says" a phrase inside a speech bubble for a indefinite amount of time, until something stops it's effect (such as the stop script block or by putting another think or say block with nothing in the textbox after it). *[Hmm... for (2) secs] (Command): The sprite "thinks" a phrase inside a cloud, for a specific amount of seconds. * '''[Hmm...] (Command): The sprite "thinks" a phrase inside a cloud for a indefinite amount of time, until something stops it's effect (such as the stop script block or by putting another think or say block with nothing in the textbox after it). *'[color - effect by (25)] (Command)': Changes a certain graphic effect's value by the specified amount. In the drop-down menu, you can choose from color, fisheye, whirl, pixelate, mosaic, brightness, and ghost. *'[color - effect to (0)] (Command)':' '''Sets a certain graphic effect's value to the specified amount. In the drop-down menu, you can choose from color, fisheye, whirl, pixelate, mosaic, brightness, and ghost. *'all graphical effects (Command): Resets all graphic effect values to 0. * '''size by (10) (Command): Change the sprite's size by a specified amount. *'size to (100) % (Command)': Sets the size of the sprite to a specified amount, in percentage, with 100% being the original size of the sprite * (size) (Value/Variable): It's the value is the current size of the sprite. Can be displayed as a stage monitor. *'show (Command)': Makes the sprite visible, unless it's ghost effect is 100 or more. *'hide (Command)': Makes the sprite invisible. The sprite can't be clicked or used to detect collision if it's hidden. *'to front (Command)': Makes the sprite go to the first layer - in front of all other sprites. *'back (1) layers (Command)': Makes the sprite go back a specific amount of layers. Sound The blocks in the sounds category generally adds sounds and music to projects. Also the sound blocks can be identified by their red-ish purple color. *'sound [meow -]' (Command): Makes the sprite play a sound, with the other blocks playing immediatly after. This means if another sound plays when the current sound is still not finished, the current sound will stop, and the next one will play. In the drop-down menu, you can choose from any sounds that are currently available in that sprite. *'sound [meow - until done]' (Command): Makes the sprite play a sound, but other blocks in the script do not play until the sound/song is finished. In the drop-down menu, you can choose from any sounds that are currently available in that sprite. *'all sounds' (Command): Stops all of the sounds in the project. *'drum (48 -) for (0.2) beats' (Command): Plays the chosen drum sound for the amount of time specified. The amount of time will be affected by the tempo. *'for '(0.2) beats' (Command): Plays one rest of silence for the specified amount of time. The amount of time will be affected by the tempo. *'note (48 -) for (0.2) beats' (Command): Plays a note of the specified pitch, instrument, and time. The amount of time will be affected by the tempo. *'instrument to (1 -)' (Command): Sets the instrument to the specified instrument. *'volume by (-10) (Command)': Changes the volume of the sounds following this block by the amount specified. *'volume to (100)% (Command)': Sets the volume to the specified amount. *'(volume)' (Value/Variable): It's the volume of the sounds in the program. The volume will also be affected by the computer's volume setting. Can be displayed as a stage monitor. *'tempo by (20)' (Command): Changes the tempo, which is the speed of the music by the amount specified. *'[set tempo to (60)' 'bpm]' (Command): Sets the tempo, which is the speed of the music to the amount specified. *'(tempo)' (Value/Variable): It's the tempo, which is the speed of the music. Can be displayed as a stage monitor. Pen The blocks in the pen category can be used to directly draw onto the stage. Also the pen blocks can be identified by their blue-green-ish color. *'clear (Command)': Clears all pen marks and stamps from the stage. *'down (Command)': The sprite starts leaving a pen trail. *'up (Command)': The sprite stops leaving a pen trail. *'pen color to [color] (Command)': Sets the pen color trail to the selected color. *'pen color by (10) (Command)': Changes the pen color (hue) by the specified value. There are 200 possible color values. *'pen color to (0) (Command)': Sets the pen color (hue) to the speicified value. There are 200 possible color values. *'pen shade by (10) (Command)': Changes the pen shade (lightness) by the specified value. There are 100 possible shade values. *'pen shade to (0) (Command)': Sets the pen shade (lightness) to the speicified value. There are 100 possible shade values. *'pen size by (1) (Command)': Changes the pen size (thickness) by the specified value. *'pen size to (1) (Command)': Sets the pen size (thickness) to the speicified value. * stamp (Command): This block stamps the sprite's current costume onto the stage. Control (under construction) Sensing (under construction) Operators (Numbers) (under construction) Variables (under construction) Accessory Blocks Scratch Sensor Board/Pico Board These blocks are used to interact with the Scratch Board/Picoboard. *'(- sensor value) (Value/Variable)': Used to check the value of the Slider, Light, Sound and Resistance sensors. *''' (Boolean): Used to check if the button is pressed, of if the Resistance sensors are connected. LEGO® Education WeDo™ kit These blocks are used to interact with the LEGO WeDo kit. They can be activated on Scratch 1.4 by clicking on the Edit menu, then "Show motor blocks". *on for (5) secs (Command): Turns the motor on for the specified amount of seconds. *on (Command): Turns the motor on. *off (Command): Turns the motor off. *power (10) (Command): Sets the power of the motor to the specified amount. *direction [this way -] (Command): Sets the direction of the motor to "this way" (clockwise), "that way" (counter-clockwise), or "reverse" (opposite direction). Also, the "(- sensor value)'''" block can be used with two more values for the WeDo kit: Tilt and Distance. External Links Scratch Help Screens (examples of blocks)